Listing 04-09: Category x Price, using elif

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 04\04.09 - Category x Price, using elif.py
# Description: Category x Price, using elif
##############################################################################

category = int(input("Enter the product category:"))
if category == 1:
    price = 10
elif category == 2:
    price = 18
elif category == 3:
    price = 23
elif category == 4:
    price = 26
elif category == 5:
    price = 31
else:
    print("Invalid category, enter a value between 1 and 5!")
    price = 0
print(f"Product price is: ${price:6.2f}")
Click here to download the file